#默认开启sshd
chkconfig sshd on

#https://www.chrome64bit.com/index.php/google-chrome-64-bit-for-linux
sudo yum install -y chromium chromium-l10n chromium-shell chromium-driver chromium-widevine
#好用的浏览器
sudo yum install -y qupzilla midori firefox

#cinnamo桌面
yum install epel-release -y
yum groupinstall "X Window system" -y
yum install lightdm -y
yum install cjs cinnamon-menus cinnamon-control-center cinnamon-translations cinnamon-settings-daemon cinnamon-screensaver nemo cinnamon-session muffin cinnamon-desktop cinnamon -y
echo "exec /usr/bin/cinnamon-session" >> ~/.xinitrc
startx
sudo ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
reboot

#! /bin/bash

# sudo不输入密码
# sudo visudo
# 在最后增加
sudo echo "super ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
#普通用户不用输入密码
sudo groupadd sudo
sudo groupadd admin
sudo usermod -G sudo super
sudo usermod -G admin super

#xfce4 desktop
sudo yum install -y @xfce-desktop

#win10-virtualBox-centOS8-解决增强功能安装失败
sudo yum update kernel -y
sudo yum install -y gcc gcc-g++ make kernel-headers kernel-devel
sudo yum install -y dkms elfutils-libelf-devel
sudo yum install -y xorg-x11-server-Xorg --skip-broken --nobest

#自定义别名
grep "alias cls='clear'" ~/.bashrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.bashrc <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
EOF
source ~/.bashrc
fi

#mirror
sudo yum install -y yum-fastestmirror

#centos使用清华源
https://mirrors.tuna.tsinghua.edu.cn/help/centos/

sudo yum install -y wget curl git tree

#使用 EPEL 源 (Extra Packages for Enterprise Linux）
sudo yum install -y epel-release
sudo mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
sudo mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
#centos7
sudo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
#centos8
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

#yum重新创建缓存
sudo yum clean all && yum makecache

#输入法
sudo yum install -y ibus ibus-table-wubi im-chooser
#打开命令行执行 ibus-setup
sudo yum install -y fcitx-configtool fcitx fcitx-table-wubi

#打开输入法设置
# gsettings set org.gnome.settings-daemon.plugins.keyboard active false

#常用开发工具
sudo yum install -y ntp net-tools sysstat
sudo yum install -y gnome-tweak-tool
sudo yum install -y chromium
sudo yum install -y wget curl git tree vim dos2unix
sudo yum install -y terminator
sudo yum install -y kernel-devel
sudo yum install -y gcc cpp gcc-c++ gd-devel glibc-doc
sudo yum install -y ncurses ncurses-devel
sudo yum install -y zlib zlib-devel
sudo yum install -y freetype-devel freetype-demos freetype-utils
sudo yum install -y openssl openssl-devel
sudo yum install -y openssh-server
sudo yum install -y bzip2-devel sqlite-devel
sudo yum install -y python-devel python36-devel
#sudo yum install -y java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64
sudo yum install -y java-latest-openjdk
sudo yum install -y gedit kate
sudo yum install -y manpages-posix-dev man-pages man-db man2html help2man most

#nodejs相关
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
# huawei cloud mirror 高版本如果安装不了，就安装低版本，最新13
#NVM_NODEJS_ORG_MIRROR=https://repo.huaweicloud.com/nodejs/ nvm install 4
#最新版本3
#NVM_IOJS_ORG_MIRROR=https://repo.huaweicloud.com/iojs/ nvm install 2

# wget https://nodejs.org/dist/v10.16.2/node-v10.16.2-linux-x64.tar.xz
# sudo tar Jxvf node-v10.16.2-linux-x64.tar.xz -C /usr/local
# sudo ln -s /usr/local/node-v10.16.2-linux-x64/bin/node /usr/bin/node
# sudo ln -s /usr/local/node-v10.16.2-linux-x64/bin/npm /usr/bin/npm
# grep "export PATH=/usr/local/node" ~/.bashrc || echo 'export PATH=/usr/local/node-v10.16.2-linux-x64/bin:$PATH' >> ~/.bashrc
# source ~/.bashrc
sudo yum install -y nodejs npm
sudo npm config set registry https://registry.npm.taobao.org
sudo npm i -g cnpm --registry https://registry.npm.taobao.org
sudo npm i -g yarn --registry https://registry.npm.taobao.org
sudo npm i -g tldr
sudo npm i -g cheat
mkdir -p ~/.config/cheat
cheat --init > ~/.config/cheat/conf.yml
# sudo ln -s /usr/local/node-v10.16.2-linux-x64/bin/cnpm /usr/bin/cnpm
# sudo ln -s /usr/local/node-v10.16.2-linux-x64/bin/yarn /usr/bin/yarn
# sudo ln -s /usr/local/node-v10.16.2-linux-x64/bin/tldr /usr/bin/tldr

#python相关
sudo yum install -y python python-pip python-setuptools
#sudo yum install -y python2 python2-pip python2-setuptools
sudo yum install -y python3 python3-pip python3-setuptools
#yum --enablerepo=ius install -y python36u python36u-pip
#升级所有过期库
# sudo pip list --outdated | awk '{print "sudo pip install --upgrade "$1}' > python-upgrade.sh
# sudo sh python-upgrade.sh
#sudo yum install -y python2-numpy python2-pandas python2-matplotlib scipy python2-jupyter-core
[ -e ~/.pip ] || sudo mkdir ~/.pip
[ -e ~/.pip/pip.conf ] || sudo touch ~/.pip/pip.conf
sudo chmod a+w ~/.pip/pip.conf
cat > ~/.pip/pip.conf <<-EOF
[global]
index-url=http://mirrors.aliyun.com/pypi/simple
EOF
sudo python3 -m pip install --upgrade pip--trusted-host mirrors.aliyun.com
#升级pip3
#sudo rm -rf /usr/bin/pip3
#sudo cp /usr/local/bin/pip3 /usr/bin/pip3
#命令行文件管理器
#pip install ranger-fm
#语法检查
#pip install --user flake8
#自动代码提示
#pip install --user jedi
#自动导入模块
#pip install --user isort
#代码格式化
#pip install --user yapf
#通过安装 pygments扩展让vim支持 50+ 种语言（包括 go/rust/scala 等，基本覆盖所有主流语言
#pip install pygments

python3 -m pip install --user --trusted-host mirrors.aliyun.com ranger-fm flake8 jedi isort yapf pygments
python3 -m pip install --user --trusted-host mirrors.aliyun.com ptpython

#vscode
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
sudo yum check-update
sudo yum install -y code

#fish & oh my fish
sudo yum install -y fish
sudo git clone https://github.com/oh-my-fish/oh-my-fish
cd oh-my-fish
bin/install --offline

[ -e touch ~/.config/fish/config.fish ] || touch ~/.config/fish/config.fish
grep "alias cls='clear'" ~/.config/fish/config.fish > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.config/fish/config.fish <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
EOF
source ~/.config/fish/config.fish
fi

#zsh
sudo yum install -y bat zsh zsh-autosuggestions autojump zsh-syntax-highlighting
#oh my zsh
sudo git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
sudo cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
#手工安装autojump
cd ~/.oh-my-zsh/custom/plugins
sudo git clone git://github.com/joelthelion/autojump.git
cd autojump
python3 install.py
#zsh plugins
sudo git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
sudo git clone https://github.com/paulirish/git-open.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/git-open
#~/.zshrc
sed -i 's/plugins=(git)/plugins=(git git-open autojump zsh-autosuggestions zsh-syntax-highlighting)/g' ~/.zshrc
source ~/.zshrc

chsh -s /usr/bin/zsh
# [ -e ~/.zshrc ] || sudo touch ~/.zshrc
#自定义别名
grep "alias cls='clear'" ~/.zshrc > /dev/null
if [ $? -eq 0 ]; then
    echo "alias was seted."
else
cat >> ~/.zshrc <<-EOF
alias cls='clear'
alias yum='sudo yum'
alias yumi='yum install -y'
alias yumr='yum remove -y'
alias yums='yum search'
alias dnf='sudo dnf'
alias dnfi='dnf install -y'
alias dnfr='dnf remove -y'
alias dnfs='dnf search'
alias npm='sudo npm'
alias cnpm='sudo cnpm'
alias yarn='sudo yarn'
alias pip='sudo -H pip --trusted-host mirrors.aliyun.com'
alias pip3='sudo -H pip3 --trusted-host mirrors.aliyun.com'
alias vim='sudo vim'
alias vi='vim'
alias l='ls -al'
alias ll='ls -l'
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
export PAGER=most
export BROWSER=firefox
export EDITOR=vim
export LANG=zh_CN.UTF-8
EOF
source ~/.zshrc
fi

#vim config
# wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x

#space-vim
sudo curl -sLf https://spacevim.org/cn/install.sh | bash
#yum grouplist | more

#第三方yum源
wget https://somata.gitee.io/image1/2019/centos8_yum_dnf_library_complete/yum.repos.all.tar.xz
sudo mkdir /var/lib/backups/
sudo mv /etc/yum.repos.d/* /var/lib/backups
sudo tar -xf yum.repos.all.tar.xz -C /
#sudo mv CentOS-Stream.repo.bak CentOS-Stream.repo
sudo yum clean all
sudo yum makecache
sudo yum --releasever 8 update dnf

#添加Elrepo源：
sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
sudo yum install -y https://www.elrepo.org/elrepo-release-8.0-2.el8.elrepo.noarch.rpm
sudo yum install -y https://www.elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
sudo yum install -y https://www.elrepo.org/elrepo-release-6-9.el6.elrepo.noarch.rpm

#添加Rpmforge源：
sudo yum install -y http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
sudo yum install -y http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

#添加Remi源：
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-8.rpm
#sudo yum install https://mirrors.huaweicloud.com/remi/enterprise/remi-release-8.rpm
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
#sudo yum install https://mirrors.huaweicloud.com/remi/enterprise/remi-release-7.rpm
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#sudo yum install https://mirrors.huaweicloud.com/remi/enterprise/remi-release-6.rpm

#添加IUS repo源：
#CentOS
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y https://centos6.iuscommunity.org/ius-release.rpm
#RHEL
sudo yum install -y https://rhel7.iuscommunity.org/ius-release.rpm
sudo yum install -y https://rhel6.iuscommunity.org/ius-release.rpm
#添加Webtatic源：
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum install -y http://repo.webtatic.com/yum/el7/webtatic-release.rpm
sudo yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum install -y http://repo.webtatic.com/yum/el6/latest.rpm
#添加nux-dextop源：
sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-2.el7.nux.noarch.rpm
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm

#aliyun-repo
http://mirrors.aliyun.com/repo/
#huaweicloud
https://mirrors.huaweicloud.com/

#homebrew
sudo groupadd admin
sudo cp /usr/bin/chown /usr/sbin/chown
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"